package com.ads.proplan.activity;

import android.app.Activity;
import android.widget.ImageView;

import com.ads.proplan.R;
import com.ads.proplan.control.CadastroControl;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.UiThread;
import com.googlecode.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {

	private boolean novo = true;
	
	@ViewById(R.id.splash_image_icone)
	public ImageView iconeImageView;

	private CadastroControl control;

	@Override
	protected void onResume() {
		super.onResume();
//		RotateAnimation anim = new RotateAnimation(0f, 350f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//		anim.setInterpolator(new LinearInterpolator());
//		anim.setRepeatCount(Animation.INFINITE);
//		anim.setDuration(300);
//		iconeImageView.startAnimation(anim);
//		timeAnimation();
		timeSplash();
		control = CadastroControl.getInstance();
		control.initialControl(this);
		novo = control.isNew();
	}
	
	@UiThread(delay = 1500)
	public void timeAnimation() {
		iconeImageView.setAnimation(null);
	}

	@UiThread(delay = 3000)
	public void timeSplash() {
		if (novo) {
			MenuCadastroActivity_.intent(this).start();
		} else {
			control.finalizeControl();
			MenuActivity_.intent(this).start();
		}
		finish();
	}

	@Override
	public void onBackPressed() {
	}


}
